package com.example.sender;

public class LongUtil {

	public static void long2Byte(byte[] bb,int start, long x) { 
        bb[ start++ ] = (byte) (x >> 56); 
        bb[ start++ ] = (byte) (x >> 48); 
        bb[ start++ ] = (byte) (x >> 40); 
        bb[ start++ ] = (byte) (x >> 32); 
        bb[ start++ ] = (byte) (x >> 24); 
        bb[ start++ ] = (byte) (x >> 16); 
        bb[ start++ ] = (byte) (x >> 8); 
        bb[ start++ ] = (byte) (x >> 0); 
  } 
	
	public static long getLong(byte[] bb,int start) { 
	       return ((((long) bb[start++ ] & 0xff) << 56) 
	               | (((long) bb[ start++] & 0xff) << 48) 
	               | (((long) bb[ start++] & 0xff) << 40) 
	               | (((long) bb[ start++] & 0xff) << 32) 
	               | (((long) bb[ start++] & 0xff) << 24) 
	               | (((long) bb[ start++] & 0xff) << 16) 
	               | (((long) bb[ start++] & 0xff) << 8) | (((long) bb[ start++] & 0xff) << 0)); 
	  } 
	
	public static void intToByteArray1(byte[] result,int start,int i) {   
		  result[start++] = (byte)((i >> 24) & 0xFF);
		  result[start++] = (byte)((i >> 16) & 0xFF);
		  result[start++] = (byte)((i >> 8) & 0xFF); 
		  result[start++] = (byte)(i & 0xFF);
		 }
}
